<?php
if ( ! defined("IN_OP") )
{
    exit("You can't access this file directly...");
}
$gametype = intval(getvar("gametype"));
$bettypegroup=getvar("bettypegroup");
$open=getvar("open");

$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];

require_once( "class_3d/RateConfig_3d.php" );
$RateConfig_3d = new RateConfig_3d($gametype);

//***************新增加***********************
//出号
if($gametype==1 || $gametype==2 || $gametype==10)
{
	$ch=array(
		array('text'=>'百位OXX出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'拾位XOX出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'个位XXO出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'全三无出期数','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
	);	
	if($gametype==1 || $gametype==2)
		$sql = "SELECT * FROM lotto_{$tbl} WHERE open >= '".date("Y-m-d",strtotime($lotto_3d['open']." -31 day"))."' and n1 >= 0 order by open";
	else
		$sql = "SELECT * FROM lotto_{$tbl} WHERE open = '".$open."' AND openbet < '".date("Y-m-d H:i:s")."' AND n1 >= 0  order by open";
	$rs = getdb($sql);
	$i=0;
	$kjhm=array();
	if($bettypegroup=='r2f') //雙面
	{
		
	}else{
		$data=array(array(),array());
		while ( ! $rs->eof )
		{
			$n1=intval($rs->f["n1"]);
			$n2=intval($rs->f["n2"]);
			$n3=intval($rs->f["n3"]);
			$kjhm[]=array($n1,$n2,$n3);

			$data[0][]=$RateConfig_3d->getBetContent(68, $rs->f['p321sd'] , TRUE);
			$data[1][]=$RateConfig_3d->getBetContent(59, $rs->f['p321bs'] , TRUE);
			
			$ch[0]['num'][intval($rs->f['n3'])]=$ch[0]['num'][intval($rs->f['n3'])]+1;
			$ch[1]['num'][intval($rs->f['n2'])]=$ch[1]['num'][intval($rs->f['n2'])]+1;
			$ch[2]['num'][intval($rs->f['n1'])]=$ch[2]['num'][intval($rs->f['n1'])]+1;
			$rs->next();
		}
	}
	$kjhm=array_reverse($kjhm);
	$ych=array();
	$l=count($kjhm);
	if($l>30) $l=30;
	for($i=0;$i<$l;$i++)
	{
		for($k=0;$k<=9;$k++)
		{
			if(!in_array($k,$kjhm[$i]) && !in_array($k,$ych))
			{
				$ch[3]['num'][$k]=$ch[3]['num'][$k]+1;	
			}
			else
				$ych[]=$k;
		}	
	}
	unset($kjhm);
}
else{
	$ch=array(
		array('text'=>'第一球出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'第二球出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'第三球出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'第四球出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'第五球出球率','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
		array('text'=>'全五无出期数','num'=>array(0,0,0,0,0,0,0,0,0,0),'max'=>-1),
	);	
	$sql = "SELECT * FROM lotto_{$tbl} WHERE open = '".$open."' AND openbet < '".date("Y-m-d H:i:s")."' AND n1 >= 0  order by open";
	$rs = getdb($sql);
	$i=0;
	$kjhm=array();
	if($bettypegroup=='r2f') //雙面
	{
		$data=array(array(),array(),array(),array(),array(),array(),array(),array(),array(),array());
		while ( ! $rs->eof )
		{
			$n1=intval($rs->f["n1"]);
			$n2=intval($rs->f["n2"]);
			$n3=intval($rs->f["n3"]);
			$n4=intval($rs->f["n4"]);
			$n5=intval($rs->f["n5"]);
			$kjhm[]=array($n1,$n2,$n3,$n4,$n5);
			$data[0][]=$RateConfig_3d->getBetContent(68, $rs->f['r2a_p54sd'] , TRUE);//万千和数单双
			$data[1][]=$RateConfig_3d->getBetContent(68, $rs->f['r2a_p53sd'] , TRUE);//万佰和数单双
			$data[2][]=$RateConfig_3d->getBetContent(68, $rs->f['r2a_p52sd'] , TRUE);//万拾和数单双
			$data[3][]=$RateConfig_3d->getBetContent(68, $rs->f['r2a_p51sd'] , TRUE);//万个和数单双
			$data[4][]=$RateConfig_3d->getBetContent(68, $rs->f['r2a_p43sd'] , TRUE);//千佰和数单双
			$data[5][]=$RateConfig_3d->getBetContent(68, $rs->f['r2a_p42sd'] , TRUE);//千拾和数单双
			$data[6][]=$RateConfig_3d->getBetContent(68, $rs->f['r2a_p41sd'] , TRUE);//千个和数单双
			$data[7][]=$RateConfig_3d->getBetContent(68, $rs->f['r2p0sd'] , TRUE);//百拾和数单双
			$data[8][]=$RateConfig_3d->getBetContent(68, $rs->f['r2p1sd'] , TRUE);//百个和数单双
			$data[9][]=$RateConfig_3d->getBetContent(68, $rs->f['r2p2sd'] , TRUE);//拾个和数单双
			$ch[0]['num'][intval($rs->f['n5'])]=$ch[0]['num'][intval($rs->f['n5'])]+1;
			$ch[1]['num'][intval($rs->f['n4'])]=$ch[1]['num'][intval($rs->f['n4'])]+1;
			$ch[2]['num'][intval($rs->f['n3'])]=$ch[2]['num'][intval($rs->f['n3'])]+1;
			$ch[3]['num'][intval($rs->f['n2'])]=$ch[3]['num'][intval($rs->f['n2'])]+1;
			$ch[4]['num'][intval($rs->f['n1'])]=$ch[4]['num'][intval($rs->f['n1'])]+1;
			$rs->next();
		}
	}else{
		$data=array(array(),array(),array());
		while ( ! $rs->eof )
		{
			$n1=intval($rs->f["n1"]);
			$n2=intval($rs->f["n2"]);
			$n3=intval($rs->f["n3"]);
			$n4=intval($rs->f["n4"]);
			$n5=intval($rs->f["n5"]);
			$kjhm[]=array($n1,$n2,$n3,$n4,$n5);
			$total = $n5 + $n4 + $n3 + $n2 + $n1;
			if ($total == 0 || $total % 2 == 0)
				$total_sd = 2;
			else
				$total_sd = 1;
			if (22 < $total)
				$total_bs = 1;
			else
				$total_bs = 2;
			$animal = 3;
			if ($n1 < $n5)
				$animal = 1;
			elseif ($n1 > $n5)
				$animal = 2;
			else
				$animal = 3;
			$data[0][]=$RateConfig_3d->getBetContent(68, $total_sd , TRUE);
			$data[1][]=$RateConfig_3d->getBetContent(59, $total_bs , TRUE);
			$data[2][]=$RateConfig_3d->getBetContent(73, $animal , TRUE);
			
			$ch[0]['num'][intval($rs->f['n5'])]=$ch[0]['num'][intval($rs->f['n5'])]+1;
			$ch[1]['num'][intval($rs->f['n4'])]=$ch[1]['num'][intval($rs->f['n4'])]+1;
			$ch[2]['num'][intval($rs->f['n3'])]=$ch[2]['num'][intval($rs->f['n3'])]+1;
			$ch[3]['num'][intval($rs->f['n2'])]=$ch[3]['num'][intval($rs->f['n2'])]+1;
			$ch[4]['num'][intval($rs->f['n1'])]=$ch[4]['num'][intval($rs->f['n1'])]+1;
			$rs->next();
		}
	}
	$kjhm=array_reverse($kjhm);
	$ych=array();
	$l=count($kjhm);
	if($l>30) $l=30;
	for($i=0;$i<$l;$i++)
	{
		for($k=0;$k<=9;$k++)
		{
			if(!in_array($k,$kjhm[$i]) && !in_array($k,$ych))
			{
				$ch[5]['num'][$k]=$ch[5]['num'][$k]+1;	
			}
			else
				$ych[]=$k;
		}	
	}
	unset($kjhm);
}

$len=count($data[0]);
$lt_list=array(array(),array(),array());
foreach($data as $keys=>$v)
{
	$item=array();
	$td=$v[0];
	$old=$v[0];
	$row=0;
	for($k=1;$k<$len;$k++)
	{
		if($old==$v[$k])	
			$td.="<br>".$v[$k];	
		else
		{
			$old=$v[$k];
			$item[]=$td;
			$row++;
			$td=$v[$k];	
		}
	}
	$item[]=$td;
	$l=count($item);
	if($l<25)
	{
		for($ii=0;$ii<(25-$l);$ii++)
			$item[]="";	
	}
	$lt_list[$keys]=$item;
}
$html="<table class='tblMy3D lt_css' style='width:747px;margin-top:5px'>";
if($gametype==1 || $gametype==2 || $gametype==10)
{
	$html.="<tr  style='font-weight:bold;color:#0000ff'><th align=center>".($gametype==1 || $gametype==2?"近30日":"今日")."
	<input type='checkbox' onclick=\"$('#ch_tr_0').toggle()\">百位&nbsp;
	<input type='checkbox' onclick=\"$('#ch_tr_1').toggle()\">十位&nbsp;
	<input type='checkbox' onclick=\"$('#ch_tr_2').toggle()\">个位&nbsp;</th>";
}
else{
	$html.="<tr   style='font-weight:bold;color:#0000ff'><th align=center nowrap>今天<input type='checkbox' onclick=\"$('#ch_tr_0').toggle()\">第一球&nbsp;
	<input type='checkbox' onclick=\"$('#ch_tr_1').toggle()\">第二球&nbsp;
	<input type='checkbox' onclick=\"$('#ch_tr_2').toggle()\">第三球&nbsp;
	<input type='checkbox' onclick=\"$('#ch_tr_3').toggle()\">第四球&nbsp;
	<input type='checkbox' onclick=\"$('#ch_tr_4').toggle()\">第五球&nbsp;</th>";
}
$html.="<th align=center>0</th><th align=center>1</th>
<th align=center>2</th>
<th align=center>3</th>
<th align=center>4</th>
<th align=center>5</th>
<th align=center>6</th>
<th align=center>7</th>
<th align=center>8</th>
<th align=center>9</th></tr>";
$maxtr=count($ch)-1;
foreach($ch as $keys=>$c)
{
	$maxnum=max($c['num']);
	if($maxnum==0) $maxnum=-1;
	$html.="<tr ".($keys<$maxtr?"style='display:none;height:25px'":"style='height:25px'")." id='ch_tr_".$keys."'><td align=center style='font-weight:bold;width:auto' nowrap>".$c['text']."</td>
		<td align=center ".($c['num'][0]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][0]."</td>
		<td align=center ".($c['num'][1]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][1]."</td>
		<td align=center ".($c['num'][2]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][2]."</td>
		<td align=center ".($c['num'][3]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][3]."</td>
		<td align=center ".($c['num'][4]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][4]."</td>
		<td align=center ".($c['num'][5]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][5]."</td>
		<td align=center ".($c['num'][6]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][6]."</td>
		<td align=center ".($c['num'][7]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][7]."</td>
		<td align=center ".($c['num'][8]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][8]."</td>
		<td align=center ".($c['num'][9]==$maxnum?"style='color:#ff0000;font-weight:bold'":"").">".$c['num'][9]."</td></tr>";
}
$html.="</table><table class='tblMy3D' style='width:747px' id='lt_table'>";
if($bettypegroup=='r2f')
{
	$html.="<tr><th colspan=25  style='height:40px!important' text-align=center>
	<span tag=\"0\" class=\"disClc onClc\">万千和数单双</span>
	<span tag=\"1\" class=\"disClc\">万佰和数单双</span>
	<span tag=\"2\" class=\"disClc\">万拾和数单双</span>
	<span tag=\"3\" class=\"disClc\">万个和数单双</span>
	<span tag=\"4\" class=\"disClc\">千佰和数单双</span>
	<span tag=\"5\" class=\"disClc\">千拾和数单双</span><br>
	<span tag=\"6\" class=\"disClc\">千个和数单双</span>
	<span tag=\"7\" class=\"disClc\">百拾和数单双</span>
	<span tag=\"8\" class=\"disClc\">百个和数单双</span>
	<span tag=\"9\" class=\"disClc\">拾个和数单双</span>
	</th></tr>";
}
else
{
	if($gametype==1 || $gametype==2 || $gametype==10)
		$html.="<tr><th colspan=25 class=title02_3d text-align=center><span tag=\"0\" id=\"chgBV0\" class=\"disClc\">百拾个OOO和数单双</span><span tag=\"1\"  id=\"chgBV1\" class=\"disClc\">百拾个OOO和数大小</span></th></tr>";
	else		
		$html.="<tr><th colspan=25 class=title02_3d text-align=center><span tag=\"0\" id=\"chgBV0\" class=\"disClc\">总单双</span><span tag=\"1\"  id=\"chgBV1\" class=\"disClc\">总大小</span><span tag=\"2\"  id=\"chgBV2\" class=\"disClc\">龙虎和</span></th></tr>";
}
foreach($lt_list as $keys=>$v)
{
	$l=count($v);
	$s=$l>=25?$l-25:0;
	$html.='<tr class="td2" style="'.($keys>=1?'display:none':'').'" id="lt_tr_'.$keys.'">';
	$row=0;
	while($s<$l)
	{
		$html.="<td style='".($row%2==1?'background-color:#E7EBEF;':'').";padding:5px;text-align:center;width:20px' valign='top'>".$v[$s]."</td>";
		$s++;
		$row++;	
	}
	$html.="</tr>";
}

$html.="</table>";
echo $html;
?>